import { defineConfig, PluginOption, ConfigEnv, UserConfig } from 'vite'
import { dtPlugins } from "@zm-pkg/plugins"
import { SERVE_CONF } from './proxy.config'

// import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [pkPlugins()],
// })

export default ( { command, mode }: ConfigEnv ): UserConfig => {
  return {
    optimizeDeps: {
      include: [
        '@wangeditor/editor-for-vue',
        '@wangeditor/editor',
        'cropperjs',
        // 'sortablejs',
      ]
    },
    css: {
      preprocessorOptions: {
        // scss: {
        //   additionalData: `@use "@styles/element.scss" as *;`,
        // },
        less: {
          modifyVars: {
            hack: `true; @import (reference) "./src/styles/antDesign.less";`
          },
          javascriptEnabled: true,
        }
      }
    },
    server: SERVE_CONF,
    plugins: [
      dtPlugins({
        isBuild: command === 'build',
      }) as PluginOption[],
    ],
  }
}
